#include "Document.hpp"
#include "Exception.hpp"

using namespace std;

Document::Document()
{
	// Init stream
	stream.resize(DEFAULT_STREAM_SIZE);
	
	// Init ptrs
	p_cursor = 0;
	p_gapStart = 0;
	p_gapLength = stream.size();
}

Document::~Document()
{
	//
}

void Document::relocateCursor(int pos)
{
	if (pos < 0 || pos > stream.size())
	{
		throw new StreamPointerException();
	}
	else
	{
		// Update cursor ptr
		p_cursor = pos;
		
		// Update gap pointers
	}
}

/// Insert a single character at the cursor
void Document::insertChar(char c)
{
	if (p_gapLength < 1)
	{
		// Insert char
		stream.at(p_gapStart) = c;
		
		// Increment gap position
		++p_gapStart;
		
		// Decrement gap length
		--p_gapLength;
	}
	else
	{
		// Resize gap
	}
}

/// Remove a single character at the cursor
void Document::backspace()
{
}